<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
</head>

<body>
    <div style="height:100x;width:100%;position: fixed;top: 0px;bottom: auto;table-layout: fixed;z-index: 10;">
        <header class="aui-bar aui-bar-nav ui-selectee">选择物料</header>
    </div>
    <div class="aui-content aui-margin-b-15" style="margin-top:50px;">
        <div class="aui-searchbar" id="search" style="position: relative;">
            <div class="aui-searchbar-input aui-border-radius">
                <i class="aui-iconfont aui-icon-search"></i>
                <div class="aui-searchbar-input">
                    <form action="javascript:doSearch();">
                        <input type="search" placeholder="请输入物料编码/名称" id="codeOrName">
                    </form>
                </div>
            </div>
            <div class="aui-btn aui-btn-primary" style="margin-right: 0.5rem;background-color: #285688" onclick="getMdMrlList()">搜索</div>

        </div>
        <!-- <ul class="aui-list aui-form-list">
            <li class="aui-list-item">
                <div class="aui-list-item-inner">
                    <div class="aui-list-item-label" style="color: #285688;">当前班组：</div>
                    <div class="aui-list-item-input">
                        <select id="teamGid" style="color: #285688;" onchange="teamChange()">
                      </select>
                    </div>
                    <i class="aui-input-addon aui-iconfont aui-icon-right"></i>
                </div>
            </li>
        </ul> -->
        <ul class="aui-list aui-list-in ui-selectee" id="tbodyHtml">
             <!-- <li class="aui-list-item ui-selectee">
                <div class="aui-list-item-inner sortable ui-selectee ui-sortable">
                    <div class="aui-list-item-title ui-selectee">套车刀</div> <input type="checkbox" name="employeeChecked" class="ui-selectee" value="LB10-653" title="套车刀"></div>
            </li>
            <li class="aui-list-item ui-selectee">
                <div class="aui-list-item-inner sortable ui-selectee ui-sortable">
                    <div class="aui-list-item-title ui-selectee">镗刀片</div> <input type="checkbox" name="employeeChecked" class="ui-selectee" value="CCGW060201-PCD" title="镗刀片"></div>
            </li>
            <li class="aui-list-item ui-selectee">
                <div class="aui-list-item-inner sortable ui-selectee ui-sortable">
                    <div class="aui-list-item-title ui-selectee">小王</div> <input type="checkbox" name="employeeChecked" class="ui-selectee" value="3" title="小王"></div>
            </li> -->
        </ul>

    </div>
    <footer class="aui-bar aui-bar-tab ui-selectee" style="color: #f5f5f5;">
        <div class="aui-bar aui-bar-btn aui-bar-btn-full ui-selectee" style="min-height: 2.8rem;font-size: 1.0rem;">
            <div class="aui-bar-btn-item ui-selectee" style="border-color: #f5f5f5;background-color: #285688;" onclick="backMrl()">确定</div>
        </div>
    </footer>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    apiready = function() {
      //getMdMrlList();
    };




    //查询物料列表
    function getMdMrlList() {
        var codeOrName= $("#codeOrName").val();
        if (codeOrName == "" || codeOrName == null || codeOrName == undefined) {
            api.toast({
                msg: '请输入物料编码/名称',
                duration: 3000
            });
            return;
        }
        var un = localStorage.getItem('un'); //登录用户
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getMdMrlList";
        var data = {
            values: { ////以表单方式提交参数（JSON对象）
                codeOrName: codeOrName,
                un: un
            }
        };
        api.ajax({
            url: url,
            method: 'post',
            dataType: 'json',
            timeout: 30,
            returnAll: false,
            data: data
        }, function(ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                if (myobj.code == '0') {
                    var list = eval(myobj.list);
                    var html = "";
                    for (var i = 0; i < list.length; i++) {
                      html += "<li class='aui-list-item ui-selectee'>";
                         html += "<div class='aui-list-item-inner sortable ui-selectee ui-sortable'>";
                             html += "<div class='aui-list-item-title ui-selectee'>" + list[i].name + "</div>";
                              html += "<input type='checkbox' name='mdMrlChecked' class='ui-selectee' value='" + list[i].code + "' title='" + list[i].name + "'></div>";
                     html += "</li>";

                    }
                    $api.html($api.byId("tbodyHtml"), html);

                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            }
        });
    }

    //选则返回函数
    function backMrl() {
        api.closeWin();
        var obj = document.getElementsByName("mdMrlChecked");
        var checkData = [];
        for (k in obj) {
            if (obj[k].checked){
              var mo={
                code:obj[k].value,
                name:obj[k].title
              }
              checkData.push(mo);
            }
        }
        var name = api.pageParam.name;
        api.execScript({
            name: name,
            script: 'setMrlList(' + JSON.stringify(checkData) + ')'
        });


    }

    //搜索
    function doSearch() {
        // var workCenterCodeS = $("#workCenterCodeS").val();
        // var serverUrl = localStorage.getItem('serverUrl');
        // var url = serverUrl + "/app/getWorkCenter";
        // var data = {
        //     values: { ////以表单方式提交参数（JSON对象）
        //         workCenterCode: workCenterCodeS,
        //         mrlCode: "",
        //         lotCode: "",
        //         qty: ""
        //     }
        // };
        // api.ajax({
        //     url: url,
        //     method: 'post',
        //     dataType: 'json',
        //     timeout: 30,
        //     returnAll: false,
        //     data: data
        // }, function(ret, err) {
        //     if (ret) {
        //         var data = JSON.stringify(ret);
        //         var myobj = eval("(" + data + ")");
        //         if (myobj.code == '0') {
        //             var mydata = eval(myobj.list);
        //             var evaluation = doT.template($api.dom('#workCenterTemp').innerHTML);
        //             $api.dom('#workCenterlist').innerHTML = evaluation(mydata);
        //         } else {
        //             api.toast({
        //                 msg: myobj.message,
        //                 duration: 3000
        //             });
        //         }
        //     }
        // });
    }

    //返回按钮
    function closeWin() {
        api.closeWin({});
    }
</script>

</html>
